<template>
  <div class="mvBox">
    <div class="video">
      <p>{{ route.query.name }}</p>
      <video :src="MvDetail" controls></video>
      <Comment :comment="comment" />
    </div>
    <div class="mvList">
      <p><span>MV</span>相关推荐</p>
      <div class="recommend">
        <div v-for="item in recommend" :key="item.id">
          <img :src="item.cover" alt="" />
          <div class="msi">
            <p><span>MV</span> {{ item.name }}</p>
            <p>{{ item.artistName }}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from "vue";
import { useRoute } from "vue-router";
import { useSendReq } from "@/store/sendReq/index";
import Comment from "@/components/comment.vue";
const sendReq = useSendReq();
const route = useRoute();
const MvDetail = ref();
const comment = reactive<comment[]>([]);
const recommend = reactive<misi[]>([]);
const params: sendParams = {
  id: route.query.id as string,
  offset: 1,
  limit: 30,
};
sendReq.getMvDetail(route.query.id as string).then((res) => {
  MvDetail.value = res.data.url;
});
sendReq.getMvCommendAndSimi(params, params.id!).then((res) => {
  comment.length = 0;
  res[0].comments.forEach((item: any) => {
    const a: comment = {};
    a.content = item.content;
    a.time = sendReq.formatDate(item.time);
    a.timeStr = item.timeStr;
    a.avatarUrl = item.user.avatarUrl;
    a.nickname = item.user.nickname;
    comment.push(a);
  });
  recommend.push(...res[1].mvs);
});
</script>

<style scoped lang="less">
.mvBox {
  width: 100%;
  height: 100%;
  display: flex;
  padding: 10px 0;
  box-sizing: border-box;
  justify-content: space-between;
  .video {
    flex: 59%;
    box-sizing: border-box;
    > P {
      margin: 10px 0;
      font-size: 20px;
      display: flex;
      align-items: center;
      font-weight: 600;
      span {
        margin-right: 10px;
        font-weight: 400;
        display: block;
        width: 58px;
        height: 36px;
        text-align: center;
        line-height: 36px;
        border: 1px solid #e83c3c;
        color: #e83c3c;
        border-radius: 5px;
      }
    }
    video {
      margin-bottom: 50px;
      height: 546px;
    }
  }
  .mvList {
    flex: 38%;
    margin-left: 25px;
    > P {
      margin: 10px 0;
      font-size: 20px;
      display: flex;
      align-items: center;
      font-weight: 600;
    }
    .recommend {
      > div {
        display: flex;
        margin-bottom: 20px;
        box-sizing: border-box;
        height: 108px;
        img {
          width: 192px;
          height: 108px;
        }
        > .msi {
          span {
            font-size: 14px;
            margin-right: 3px;
            text-align: center;
            line-height: 36px;
            border: 1px solid #e83c3c;
            color: #e83c3c;
            border-radius: 5px;
            padding: 2px;
            box-sizing: border-box;
          }
          width: 200px;
          padding-left: 10px;
          margin: 2px 0;
          box-sizing: border-box;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          p:nth-child(1) {
            font-size: 20px;
          }
        }
      }
    }
  }
}
</style>
